package com.cskaoyan.shiro;

import org.apache.shiro.web.servlet.Cookie;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;

/**
 * @author rebaogu
 * @description
 * @date 2022.04.11 14:17
 * @package com.cskaoyan.shiro
 * @Classname CustomWebSessionManager
 */
public class CustomWebSessionManager extends DefaultWebSessionManager {
    @Override
    protected Serializable getSessionId(ServletRequest request, ServletResponse response) {

        HttpServletRequest request1 = (HttpServletRequest) request;
        String header1 = request1.getHeader("X-CskaoyanMarket-Admin-Token");
        if (header1 != null && !"".equals(header1)) {
            return header1;
        }

        String header2 = request1.getHeader("X-CskaoyanMarket-Token");
        if (header2 != null && !"".equals(header2)) {
            return header2;
        }
        return super.getSessionId(request, response);
    }
}
